Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Log] CLILogging.configure returns as early as possible #228

Merged
merged 1 commit into from
Jan 25, 2021

Conversation

jiasli
Copy link
Member

@jiasli jiasli commented Jan 22, 2021

Check whether CLILogging already has been configured and return as early as possible, otherwise, calls like

self.log_level = self._determine_log_level(args)

is totally unnecessary and is merely a waste of time.

@yonzhan
Copy link
Collaborator

yonzhan commented Jan 22, 2021

Log

@jiasli jiasli merged commit c6f2aed into microsoft:master Jan 25, 2021
@jiasli jiasli deleted the logger-configured branch January 25, 2021 10:05
@jiasli jiasli mentioned this pull request Jan 26, 2021
Comment on lines +129 to +133
root_logger = logging.getLogger()

if root_logger.handlers:
# handlers already configured
return
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When run in pytest environment, root_logger is already set by pytest. If we don't return here before cli_logger.propagate = False, cli_logger.propagate = False will take effect and intercepts all logs sent to cli_loggers.

With this change, all logs will be handled by pytest directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants